home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / cuj9204.zip / 1004010B < prev    next >
Text File  |  1992-06-02  |  348b  |  19 lines

  1. /* div function */
  2. #include <stdlib.h>
  3.  
  4. div_t (div)(int numer, int denom)
  5.     {    /* compute int quotient and remainder */
  6.     div_t val;
  7.  
  8.     val.quot = numer / denom;
  9.     val.rem = numer - denom * val.quot;
  10.     if (val.quot < 0 && 0 < val.rem)
  11.         {    /* fix remainder with wrong sign */
  12.         val.quot += 1;
  13.         val.rem -= denom;
  14.         }
  15.     return (val);
  16.     }
  17.  
  18.  
  19.